﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BL;

namespace OpenLeuvenPortaal
{
    public partial class DeveloperAppsDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            getAllApplicationsPerDeveloper();
            LblApplicatieAppLink.Visible = true;
        }


        public List<Model.Applicaty> getAllApplicationsPerDeveloper()
        {
            dbopenleuvenDataContext db = new dbopenleuvenDataContext();

            List<Model.Applicaty> mijnApplicaties =new List<Applicaty>();

            try
            {
                int myid = int.Parse(Request.QueryString["ID"].ToString());

                var result = from a in db.Applicaties where a.AppID == myid select a;
                //var result = from a in db.Applicaties join d in db.Gebruikers on a.UserID equals d.UserID where d.RolID == 5 select a;
                mijnApplicaties = result.ToList();



                foreach (Applicaty a in mijnApplicaties)
                {
                    HyperLink hyperlink = new HyperLink();
                    hyperlink.Text = Convert.ToString(a.AppLink);
                    hyperlink.ID = Convert.ToString(a.AppID);
                    hyperlink.NavigateUrl = "http://" + a.AppLink;
                    //hyperlink.Attributes["src"]=(a.AppLink);
                    LblApplicatieAppLink.Controls.Add(hyperlink); // Adding the hyperlink in PlaceHolder


                    //Adding row 1 with name
                    
                    TableCell1.Text = "Applicatie Naam";

                    txb1.Text = a.AppNaam;
                    txb1.ReadOnly = true;                   

                    //Adding row 2 with URL
                    TableCell2.Text = "Applicatie Link";

                    TextBox2.Text = a.AppLink;
                    TextBox2.ReadOnly = true;

                    TableCell3.Text = "Applicatie Beschrijving";

                    TextBox3.Text = a.AppComment;
                    TextBox3.ReadOnly = true;

                }
              //  return mijnApplicaties;

            }catch(Exception e)
            {
               // return mijnApplicaties;
                Response.Write("ER is geen appid beschikbaar dus u kan geen details zien.");
            }

            return mijnApplicaties;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }
    }
}